@echo off
:Compile Stuff

rem call stpb.bat st_proc personalplaner_procs
rem tools\prepsql.exe personalplaner_procs.sql out\prs_procs.sql

echo Merge script...
rem copy sp_header.sql /b + out\prs_procs.sql /b out\prs_procs.tmp >nul
rem copy out\prs_procs.tmp out\prs_procs.sql >nul

echo Merge prs_procs
del out\prs_procs.sql >nul
if exist st_proc\proclist.txt del st_proc\proclist.txt >nul
dir /b st_proc\*.sql >>st_proc\proclist.txt  
tools\mergesql.exe st_proc prs_procs.sql
if exist st_proc\proclist.txt del st_proc\proclist.txt >nul


echo Merge prs_views
del out\prs_views.sql >nul
if exist prs_view\proclist.txt del prs_view\proclist.txt >nul
dir /b prs_view\*.sql >>prs_view\proclist.txt  
tools\mergesql.exe prs_view prs_views.sql
if exist prs_view\proclist.txt del prs_view\proclist.txt >nul

echo Copy files...
rem copy sp_header.sql /b + prs_procs.sql /b out\prs_procs.sql >nul
copy prs_procs.sql /b out\prs_procs.sql >nul
copy prs_views.sql /b out\prs_views.sql

copy prs_tabs.sql /b out\prs_tabs.sql >nul
copy prs_users.sql /b out\prs_users.sql
copy prs_userrights.sql /b out\prs_userrights.sql
copy prs_options.sql /b out\prs_options.sql
copy sp_header.sql /b out\prs_versioninfo.sql

if exist Updates\prs_procs.sql del Updates\prs_procs.sql >nul
copy prs_procs.sql Updates\prs_procs.sql

echo Clean up
if exist prs_procs.sql del prs_procs.sql >nul
if exist prs_views.sql del prs_views.sql >nul